import request from '@/axios';
import { baseUrl } from '@/config/env';


// 用户名登录
export const loginByUsername = (userAccount, password, code, redomStr) => request({
  url: baseUrl + '/users/login',
  method: 'post',
  meta: {
    isToken: false
  },
  data: {
    userAccount,
    password,
    code,
    redomStr
  }
})

// 注册
export const register = (data) => request({
  url: baseUrl + '/users/register',
  method: 'post',
  meta: {
    isToken: false
  },
  data: data
})

export const getUserInfo = (userId) => request({
  url: baseUrl + `/users/${userId}`,
  method: 'get'
});

export const refreshToken = () => request({
  url: baseUrl + '/user/refresh',
  method: 'post'
})

export const getMenu = (type = 0) => request({
  url: baseUrl + '/user/getMenu',
  method: 'get',
  params: {
    type
  }
});

export const getTopMenu = () => request({
  url: baseUrl + '/user/getTopMenu',
  method: 'get'
});

export const sendLogs = (list) => request({
  url: baseUrl + '/user/logout',
  method: 'post',
  data: list
})

export const logout = () => request({
  url: baseUrl + '/user/logout',
  meta: {
    isToken: false
  },
  method: 'get'
})